/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ecom.perssistance;

import ecom.entity.ProductBean;
import org.hibernate.Session;
import org.hibernate.Transaction;

/**
 *
 * @author simonrichard
 */
public class TestProducts {

    public static void main(String[] args) {
//
//        HibernateFactory.buildSessionFactory();
//
//        Session session = HibernateFactory.openSession();
//        Transaction tx = session.beginTransaction();
//
//        Object obj = session.load(ProductBean.class, 0);
//        tx.commit();
//
//        ProductBean p = (ProductBean) obj;

//        ProductBean p = (ProductBean) productDAO.find(ProductBean.class, 0);

        ProductDAO productDAO = new ProductDAO();

        ProductBean newP = new ProductBean();
//        newP.setId(new Integer(2));
        newP.setDescription("Vin d'excellence");
        newP.setName("Chateau cheval blanc");
        newP.setPrice(400);

        newP.setCategoryId(1);

        productDAO.create(newP);

        ProductBean p = (ProductBean) productDAO.find(0);
        System.out.println(p);
    }
}
